﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace JetRetail
{
    class WorkSetting
    {

        /// <summary>
        /// Получить ConnectionStrings из app.config
        /// </summary>
        /// <returns></returns>
        public string GetConnectionString()
        {
            return ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        }

        public int GetInterfaceType()
        {
            return Convert.ToInt32(ConfigurationManager.AppSettings["InterfaceType"]);
        }

        public int GetRegistratorType()
        {
            return Convert.ToInt32(ConfigurationManager.AppSettings["RegistratorType"]);
        }

        public string GetCopyCheckName()
        {
            return Convert.ToString(ConfigurationManager.AppSettings["CopyCheckName"]);
        }

        public int GetChemeColor()
        {
            return Convert.ToInt32(ConfigurationManager.AppSettings["UseGrinBackColorforEmptyArea"]);
        }

        public int GetTypeCompany()
        {
            if (!System.String.IsNullOrEmpty(Convert.ToString(ConfigurationManager.AppSettings["CompanyN"])))
            {
                return Convert.ToInt32(ConfigurationManager.AppSettings["CompanyN"]);
            }
            else
            {
                return -1;
            }
        }

        public int GetMercPortNum()
        {
            return Convert.ToInt32(ConfigurationManager.AppSettings["MercPortNum"]);
        }

        public int GetMercBaudRate()
        {
            return Convert.ToInt32(ConfigurationManager.AppSettings["MercBaudRate"]);
        }

        public int GetSchtrichPass() 
        {
            return Convert.ToInt32(ConfigurationManager.AppSettings["SchtrichPass"]);
        }

        public int GetSchtrichPassKassir()
        {
            return Convert.ToInt32(ConfigurationManager.AppSettings["SchtrichPassKassir"]);
        }

        public string GetSerialNumberForVm8119()
        {
            try
            {
                return Convert.ToString(ConfigurationManager.AppSettings["VM8119SerialNumber"]);
            }
            catch (Exception)
            {
                return "000000";
            }
            
        }

        public string GetCompanyNameForVm8119()
        {
            try
            {
                return Convert.ToString(ConfigurationManager.AppSettings["VM8119CompanyName"]);
            }
            catch (Exception)
            {
                return "";
            }
        }

        public string GetRTTForVm8119()
        {
            try
            {
                return Convert.ToString(ConfigurationManager.AppSettings["VM8119RTT"]);
            }
            catch (Exception)
            {
                return "";
            }
        }

        public string GetAdressForVm8119()
        {
            try
            {
                return Convert.ToString(ConfigurationManager.AppSettings["VM8119Address"]);
            }
            catch (Exception)
            {
                return "";
            }
        }


        public string GetOperationTimeForVm8119()
        {
            try
            {
                return Convert.ToString(ConfigurationManager.AppSettings["VM8119OperationTime"]);
            }
            catch (Exception)
            {
                return "";
            }
        }

        public string GetOperationTimeWorkDayForVm8119()
        {
            try
            {
                return Convert.ToString(ConfigurationManager.AppSettings["VM8119OperationTimeWorkDay"]);
            }
            catch (Exception)
            {
                return "";
            }
        }

        public string GetOperationTimeHoliDayForVm8119()
        {
            try
            {
                return Convert.ToString(ConfigurationManager.AppSettings["VM8119OperationTimeHoliDay"]);
            }
            catch (Exception)
            {
                return "";
            }
        }


        public int GetParamCopyCheckAfterDiscountCheck()
        {
            try
            {
                return Convert.ToInt32(ConfigurationManager.AppSettings["CopyCheckAfterDiscountCheck"]);
            }
            catch (Exception)
            {
                return 0;
            }
        }

        /// <summary>
        /// Получаем кол-во позиций, при котором будет выдаваться предупреждение, что осталось мало товара из обязательного перечня
        /// </summary>
        /// <returns></returns>
        public int GetCountPositionForMessageByMustHaveInApt()
        {
            try
            {
                return Convert.ToInt32(ConfigurationManager.AppSettings["CountPositionForMessageByMustHaveInApt"]);
            }
            catch (Exception)
            {
                return -1;
            }
        }

        /// <summary>
        /// Получаем кол-во позиций, при котором будет выдаваться предупреждение, что осталось мало товара из обязательного беларусского перечня
        /// </summary>
        /// <returns></returns>
        public int GetCountPositionForMessageByMustHaveBelInApt()
        {
            try
            {
                return Convert.ToInt32(ConfigurationManager.AppSettings["CountPositionForMessageByMustHaveBelInApt"]);
            }
            catch (Exception)
            {
                return -1;
            }
        }

    }
}
